package com.huifaapp.mall.activity;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.anlia.progressbar.CircleBarView;
import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.FutureTarget;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.huifaapp.mall.APP;
import com.huifaapp.mall.R;
import com.huifaapp.mall.activity.Homefragment.MessageActivity;
import com.huifaapp.mall.activity.Homefragment.ShengqianActvity.ShengQianActivity;
import com.huifaapp.mall.activity.Homefragment.ShengqianActvity.ShengqianLogingActivity;
import com.huifaapp.mall.adapter.HomeLivingMoneyFindGoodGoodsViewAdapter;
import com.huifaapp.mall.adapter.HomeLivingMoneyPopularActivitiesViewAdapter;
import com.huifaapp.mall.adapter.HomeLivingMoneyTGridViewAdapter;
import com.huifaapp.mall.adapter.TmallchoicenessAdapter;
import com.huifaapp.mall.adapter.TmallchoicenessListAdapter;
import com.huifaapp.mall.afinal.SPConstants;
import com.huifaapp.mall.api.ApiManager;
import com.huifaapp.mall.api.ObserverCallback;
import com.huifaapp.mall.bean.AdvertoneBean;
import com.huifaapp.mall.bean.Advertthreethree;
import com.huifaapp.mall.bean.AdverttwoBean;
import com.huifaapp.mall.bean.BannersBean;
import com.huifaapp.mall.bean.ClinimsgBean;
import com.huifaapp.mall.bean.CremoneyBean;
import com.huifaapp.mall.bean.GoodFindBean;
import com.huifaapp.mall.bean.HotingBean;
import com.huifaapp.mall.bean.Huishengqian.Index;
import com.huifaapp.mall.bean.JDcomjPlistBean;
import com.huifaapp.mall.bean.JDlianjie;
import com.huifaapp.mall.bean.ModelsBean;
import com.huifaapp.mall.bean.RankingBean;
import com.huifaapp.mall.bean.RedBean;
import com.huifaapp.mall.bean.ShareImageBean;
import com.huifaapp.mall.dialogs.LoadingDialog;
import com.huifaapp.mall.uitils.AUniqueIdentifier;
import com.huifaapp.mall.uitils.Contig;
import com.huifaapp.mall.uitils.GlideImageLoader;
import com.huifaapp.mall.uitils.NoScrollGridView;
import com.huifaapp.mall.uitils.ObservableScrollView;
import com.huifaapp.mall.uitils.ShareUtils;
import com.huifaapp.mall.uitils.UtilsImage;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.just.library.AgentWeb;
import com.kepler.jd.Listener.LoginListener;
import com.kepler.jd.login.KeplerApiManager;
import com.kepler.jd.sdk.bean.KeplerAttachParameter;
import com.kepler.jd.sdk.exception.KeplerBufferOverflowException;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.squareup.okhttp.Request;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;

import static com.huifaapp.mall.afinal.Constants.savePath;

/**
 * Created by Administrator on 2017-11-27.
 */



@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class HomeLivingMoneyFragement extends Fragment implements ObservableScrollView.ScrollViewListener {

    private Banner cycleViewPager,cycleViewPager_Cremoney,cycleViewPager_one;
    private  boolean iskejian=false;
    private NoScrollGridView gv_homeliving_gridviewT;
    private NoScrollGridView gv_homeliving_findGoodGoods;
    private NoScrollGridView gv_homeliving_Popular_activities;
    private ObservableScrollView myscoll;
    private LinearLayout search_ll;
    private ImageView iv_home_btn_xiaoxi;
    private ImageView iv_home_btn_xiaoxi_b;
    ArrayList<String> list=new ArrayList<String>();
    BannersBean listban;
    CremoneyBean listC;
    AdvertoneBean listone;
    AdverttwoBean listtwo;
    Advertthreethree listthre;
    private ImageView iv_home_ranking_ranNo1;
    private ImageView iv_home_ranking_ranNo2;
    private ImageView iv_home_ranking_ranNo3;
    private ImageView iv_home_ranking_ranNo4;
    private ImageView iv_home_ranking_ranNo5;
    private ImageView iv_advertone;
    private ImageView iv_advertwo;
    private ImageView iv_adverthree;
    private TextView tv_today_money;
    private LinearLayout ll_homeliving_huisheng_money;
    private ImageView iv_homeliving_Rise;
    private ImageView iv_homeliving_decline;
    private TextView tv_homeliving_Available_balance;
    private TextView tv_homeliving_Withdrawals;//提现
    private TextView tv_homeliving_totalProfit;
    private TextView tv_homeliving_totalComsum;
    private LinearLayout ll_web_container_home;
    private WebView webview_home;
    private ImageView iv_advermoney_banner;
    private Banner cycleViewPager_two,cycleViewPager_thre;

    protected AgentWeb mAgentWeb;
    WebView mWebView;
    LoadingDialog loadingDialog;
    private LinearLayout ll_home_sear;
    private TextView tv_devider_home;
    private LinearLayout ll_faxianhaohuo;
    private ImageView iv_redyouhuiquan;
    private LinearLayout ll_remenhuodong;
    RedBean listred;
    ArrayList<String> listid=new ArrayList<>();
    private LinearLayout ll_hongbao;
    private ImageView iv_cancel_dialog_red;
    private ImageView dialog_tmall_floatingActionButton_home;
    private ImageView dialog_tmall_floatingActionButton_share_home;
    private ArrayList<JDcomjPlistBean.DataBean.ListBean> jDcomjPlistlist;
    private XRecyclerView mRecyclerview;
    private XRecyclerView list_xrecyclerView;
    private LinearLayout rl_bottom;
    private TmallchoicenessAdapter myRecycleViewAdapter;
    private  int curr;
    private TmallchoicenessListAdapter tmallchoicenessListAdapter;
    private  String  GOODSURL=ApiManager.BASE_NIUPAI_URL+"jd"+"/goods";//，精选，爆品二合一接口
    //    private  String GETCONURLURL=ApiManager.BASE_NIUPAI_URL+Contig.typex+"/getConUrl";//京东获取优惠劵二合一链接
    private int location;
    public boolean isSelected = true;
    private int lvgv=0;
    ArrayList<String> idlist = new ArrayList<>();
    ArrayList<String> idlistlv = new ArrayList<>();
    private static final int SHARET_WXHY = 517;
    public static Map<Integer, Boolean> hmap;
    ArrayList<String>  image=new ArrayList<>();
    ArrayList<String>  imagemory=new ArrayList<>();
    ArrayList<String>  imageone=new ArrayList<>();
    ArrayList<String> imagetwo=new ArrayList<>();
    ArrayList<String>  imagethre=new ArrayList<>();
    private View viewLayout;
    private JDlianjie jDlianjiebean;
    private String datayouhui;
    private String datalisnajie;
    KeplerAttachParameter mKeplerAttachParameter = new KeplerAttachParameter();//这个是即时性参数  可以设置
    private ImageView imageViewkejian;
    private Handler handler;
    private CircleBarView circleBarView;
    private TextView tvprogress;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        viewLayout = inflater.inflate(R.layout.home_fragment, container, false);
        dialog_tmall_floatingActionButton_home = (ImageView) viewLayout.findViewById(R.id.dialog_tmall_floatingActionButton_home);
        //分享
        dialog_tmall_floatingActionButton_share_home = (ImageView) viewLayout.findViewById(R.id.dialog_tmall_floatingActionButton_share_home);
        jDcomjPlistlist = new ArrayList<JDcomjPlistBean.DataBean.ListBean>();
        mRecyclerview = (XRecyclerView) viewLayout.findViewById(R.id.shopweiniyuijian_XRecyclerView_home);
        list_xrecyclerView = (XRecyclerView) viewLayout.findViewById(R.id.list_xrecyclerView_home);
        myRecycleViewAdapter = new TmallchoicenessAdapter(jDcomjPlistlist, getActivity(), "home");
        mRecyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false));
        mRecyclerview.setAdapter(myRecycleViewAdapter);
        myRecycleViewAdapter.notifyDataSetChanged();
        if(SPUtils.getInstance().getString(SPConstants.KEY_ISSTORE).equals("1")){
            dialog_tmall_floatingActionButton_share_home.setVisibility(View.VISIBLE);
        }else{
            dialog_tmall_floatingActionButton_share_home.setVisibility(View.GONE);
        }

        //xrecycleview的监听
        mRecyclerview.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() { //刷新
                curr = 0;
                initjplistHttp();
                LoadIxTongRed();
                LoadIsShow();
                LoadHomeBanners();
                LoadHomeModels();
                LoadHomeAdvertthree();
                LoadHomeAdvertone();
                LoadHomeClinimsg();
                LoadHomeGoodfinds();
                LoadHomeAdverttwo();
                LoadHomeRanking();
                LoadHomeHoting();
                ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_w);
                search_ll.setBackgroundColor(Color.argb((int) 0, 227, 29, 26));//AGB由相关工具获得，或者美工提供
                iv_home_btn_xiaoxi.setVisibility(View.VISIBLE);
                iv_home_btn_xiaoxi_b.setVisibility(View.GONE);
                tv_devider_home.setVisibility(View.GONE);

            }

            @Override
            public void onLoadMore() {  //加载
                curr++;
                initjplistHttp();
            }
        });
        tmallchoicenessListAdapter = new TmallchoicenessListAdapter(getActivity(), jDcomjPlistlist, "home");
        list_xrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        list_xrecyclerView.setAdapter(tmallchoicenessListAdapter);
        list_xrecyclerView.setVisibility(View.GONE);
        list_xrecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                curr = 0;
                initjplistHttp();

            }

            @Override
            public void onLoadMore() {
                curr++;
                initjplistHttp();
            }
        });
        initjplistHttp();
        dialog_tmall_floatingActionButton_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isSelected) {
                    isSelected = false;
                    mRecyclerview.setVisibility(View.GONE);
                    list_xrecyclerView.setVisibility(View.VISIBLE);
                    lvgv = 1;
                    dialog_tmall_floatingActionButton_home.setImageResource(R.drawable.btn_blue_qiehuan_1);

                } else {
                    isSelected = true;
                    list_xrecyclerView.setVisibility(View.GONE);
                    mRecyclerview.setVisibility(View.VISIBLE);
                    lvgv = 0;
                    dialog_tmall_floatingActionButton_home.setImageResource(R.drawable.btn_icon_leibiao);
                }
            }
        });


        //分享按钮
        dialog_tmall_floatingActionButton_share_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (lvgv == 0) {
                    Log.e("数据Toady", Contig.checkedIndexltmalgrid + "-=====Contig.checkedIndex===id");
                    if (Contig.checkedIndexltmalgrid.size() == 0) {
                        Toast.makeText(getActivity(), "没有选择，请选择再分享！", Toast.LENGTH_SHORT).show();
                    } else {
                        for (int i = 0; i < Contig.checkedIndexltmalgrid.size(); i++)
                            idlist.add(jDcomjPlistlist.get(Contig.checkedIndexltmalgrid.get(i)).getId());

                        Log.e("数据Toady", idlist + "-===========id");


                        StringBuffer permission = new StringBuffer();
                        for (int i = 0; i < idlist.size(); i++) {
                            if (i == 0) {
                                permission.append(idlist.get(i));
                            } else {
                                permission.append("," + idlist.get(i));
                            }
                            Contig.listididtml.add(idlist.get(i));

                        }

                        ApiManager
                                .getInstance()
                                .getApiServer()
                                .getShareImage(SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN), AUniqueIdentifier.getDeviceId(getActivity()), permission.toString())
                                .compose(ApiManager.<ShareImageBean>handlResult())
                                .subscribe(new ObserverCallback<ShareImageBean>(getActivity()) {
                                    @Override
                                    protected void onSuccessful(ShareImageBean resp) {

                                        saveImage(resp.getPoster(), resp.getFailure(), SHARET_WXHY);
                                        if (Contig.checkedIndexltmalgrid.size() > 0) {
                                            for (int a = 0; a < Contig.checkedIndexltmalgrid.size(); a++) {
                                                Contig.ShareListtmll.add(jDcomjPlistlist.get(Contig.checkedIndexltmalgrid.get(a)).getId());
                                            }
                                        }
                                        myRecycleViewAdapter = new TmallchoicenessAdapter(jDcomjPlistlist, getActivity(), "shop");
                                        mRecyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false));
                                        mRecyclerview.setAdapter(myRecycleViewAdapter);

                                    }

                                    @Override
                                    protected void onError(String code, String errMsg) {
                                        ToastUtils.showShortSafe(errMsg);
                                    }
                                });
                        idlist.clear();
                    }
                } else if (lvgv == 1) {
                    Log.e("数据Toady", Contig.checkedIndexltmallist + "-=====Contig.checkedIndex===id");
                    if (Contig.checkedIndexltmallist.size() == 0) {
                        Toast.makeText(getActivity(), "没有选择，请选择再分享！", Toast.LENGTH_SHORT).show();
                    } else {
                        for (int i = 0; i < Contig.checkedIndexltmallist.size(); i++)
                            idlistlv.add(jDcomjPlistlist.get(Contig.checkedIndexltmallist.get(i)).getId());

                        Log.e("数据Toady", idlistlv + "-===========id");


                        StringBuffer permission = new StringBuffer();
                        for (int i = 0; i < idlistlv.size(); i++) {
                            if (i == 0) {
                                permission.append(idlistlv.get(i));
                            } else {
                                permission.append("," + idlistlv.get(i));
                            }
                            Contig.listididlisttml.add(idlistlv.get(i));

                        }

                        ApiManager
                                .getInstance()
                                .getApiServer()
                                .getShareImage(SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN), AUniqueIdentifier.getDeviceId(getActivity()), permission.toString())
                                .compose(ApiManager.<ShareImageBean>handlResult())
                                .subscribe(new ObserverCallback<ShareImageBean>(getActivity()) {
                                    @Override
                                    protected void onSuccessful(ShareImageBean resp) {

                                        saveImage(resp.getPoster(), resp.getFailure(), SHARET_WXHY);
                                        if (Contig.checkedIndexltmallist.size() > 0) {
                                            for (int a = 0; a < Contig.checkedIndexltmallist.size(); a++) {
                                                Contig.ShareListlvtmll.add(jDcomjPlistlist.get(Contig.checkedIndexltmallist.get(a)).getId());
                                            }
                                        }

                                        tmallchoicenessListAdapter = new TmallchoicenessListAdapter(getActivity(), jDcomjPlistlist, "shop");
                                        list_xrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
                                        list_xrecyclerView.setAdapter(tmallchoicenessListAdapter);
                                    }

                                    @Override
                                    protected void onError(String code, String errMsg) {
                                        ToastUtils.showShortSafe(errMsg);
                                    }
                                });
                        idlistlv.clear();
                    }
                }

            }
        });

        View banner_frg01 = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_homeliving_money, null);
        mRecyclerview.addHeaderView(banner_frg01);
        list_xrecyclerView.addHeaderView(banner_frg01);
        hmap = new HashMap<>();
        circleBarView = (CircleBarView) banner_frg01.findViewById(R.id.circle_view);
        tvprogress = (TextView) banner_frg01.findViewById(R.id.text_progress);
        //imageViewkejian = (ImageView) banner_frg01.findViewById(R.id.kejian);
        gv_homeliving_gridviewT = (NoScrollGridView) banner_frg01.findViewById(R.id.gv_homeliving_gridviewT);
        gv_homeliving_findGoodGoods = (NoScrollGridView) banner_frg01.findViewById(R.id.gv_homeliving_findGoodGoods);
        gv_homeliving_Popular_activities = (NoScrollGridView) banner_frg01.findViewById(R.id.gv_homeliving_Popular_activities);
        ll_remenhuodong = (LinearLayout) banner_frg01.findViewById(R.id.ll_remenhuodong);
        myscoll = (ObservableScrollView) banner_frg01.findViewById(R.id.myscoll);
        myscoll.setScrollViewListener(this);
        search_ll = (LinearLayout) viewLayout.findViewById(R.id.search_ll);
        tv_devider_home = (TextView) viewLayout.findViewById(R.id.tv_devider_home);
        iv_home_btn_xiaoxi = (ImageView) viewLayout.findViewById(R.id.iv_home_btn_xiaoxi);
        iv_home_btn_xiaoxi_b = (ImageView) viewLayout.findViewById(R.id.iv_home_btn_xiaoxi_b);
        iv_home_btn_xiaoxi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isLogin(getActivity(), true)) {
                    return;
                }
                Intent intent = new Intent(getActivity(), MessageActivity.class);
                startActivity(intent);
            }
        });
        iv_home_btn_xiaoxi_b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isLogin(getActivity(), true)) {
                    return;
                }
                Intent intent = new Intent(getActivity(), MessageActivity.class);
                startActivity(intent);
            }
        });
        iv_home_ranking_ranNo1 = (ImageView) banner_frg01.findViewById(R.id.iv_home_ranking_ranNo1);
        iv_home_ranking_ranNo2 = (ImageView) banner_frg01.findViewById(R.id.iv_home_ranking_ranNo2);
        iv_home_ranking_ranNo3 = (ImageView) banner_frg01.findViewById(R.id.iv_home_ranking_ranNo3);
        iv_home_ranking_ranNo4 = (ImageView) banner_frg01.findViewById(R.id.iv_home_ranking_ranNo4);
        iv_home_ranking_ranNo5 = (ImageView) banner_frg01.findViewById(R.id.iv_home_ranking_ranNo5);
        iv_advertone = (ImageView) banner_frg01.findViewById(R.id.iv_advertone);
        iv_advertwo = (ImageView) banner_frg01.findViewById(R.id.iv_advertwo);
        iv_adverthree = (ImageView) banner_frg01.findViewById(R.id.iv_adverthree);
        tv_today_money = (TextView) banner_frg01.findViewById(R.id.tv_today_money);
        ll_faxianhaohuo = (LinearLayout) banner_frg01.findViewById(R.id.ll_faxianhaohuo);
        ll_homeliving_huisheng_money = (LinearLayout) banner_frg01.findViewById(R.id.ll_homeliving_huisheng_money);
        iv_homeliving_Rise = (ImageView) banner_frg01.findViewById(R.id.iv_homeliving_Rise);
        iv_homeliving_decline = (ImageView) banner_frg01.findViewById(R.id.iv_homeliving_decline);
        tv_homeliving_Available_balance = (TextView) banner_frg01.findViewById(R.id.tv_homeliving_Available_balance);
        tv_homeliving_Withdrawals = (TextView) banner_frg01.findViewById(R.id.tv_homeliving_Withdrawals);
        tv_homeliving_totalProfit = (TextView) banner_frg01.findViewById(R.id.tv_homeliving_totalProfit);
        tv_homeliving_totalComsum = (TextView) banner_frg01.findViewById(R.id.tv_homeliving_totalComsum);
        ll_web_container_home = (LinearLayout) banner_frg01.findViewById(R.id.ll_web_container_home);
        webview_home = (WebView) banner_frg01.findViewById(R.id.webview_home);
        cycleViewPager = (Banner) banner_frg01.findViewById(R.id.fragment_cycle_viewpager_content_homeliving_money);
        cycleViewPager_Cremoney = (Banner) banner_frg01.findViewById(R.id.fragment_cycle_viewpager_content_homeliving_money_banner);
        cycleViewPager_one = (Banner) banner_frg01.findViewById(R.id.cycleViewPager_one);
        cycleViewPager_two = (Banner) banner_frg01.findViewById(R.id.cycleViewPager_two);
        cycleViewPager_thre = (Banner) banner_frg01.findViewById(R.id.cycleViewPager_thre);
        iv_advermoney_banner = (ImageView) banner_frg01.findViewById(R.id.iv_advermoney_banner);
        int visibility = iv_advermoney_banner.getVisibility();
        if (visibility==0){
            iv_advermoney_banner.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intentlog = new Intent(getActivity(),ShengqianLogingActivity.class);
                    startActivity(intentlog);

                }
            });

        }


        iv_redyouhuiquan = (ImageView) banner_frg01.findViewById(R.id.iv_redyouhuiquan);
        ll_hongbao = (LinearLayout) banner_frg01.findViewById(R.id.ll_hongbao);
        iv_cancel_dialog_red = (ImageView) banner_frg01.findViewById(R.id.iv_cancel_dialog_red);
        iv_cancel_dialog_red.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ll_hongbao.setVisibility(View.GONE);
                iv_cancel_dialog_red.setVisibility(View.GONE);
            }
        });
        ll_home_sear = (LinearLayout) viewLayout.findViewById(R.id.ll_home_sear);
        ll_home_sear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), SearActivity.class);
                startActivity(intent);
            }
        });
        LoadIxTongRed();
        LoadIsShow();
        LoadHomeBanners();
        LoadHomeModels();
        LoadHomeAdvertthree();
        LoadHomeAdvertone();
        LoadHomeClinimsg();
        LoadHomeGoodfinds();
        LoadHomeAdverttwo();
        LoadHomeRanking();
        LoadHomeHoting();
        mRecyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int x, int y) {
                super.onScrolled(recyclerView, x, y);
                Log.i("首页滚动","x----->"+x+ "y--->" + y );
                if (y == 0) {
                    ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_w);
                    search_ll.setBackgroundColor(Color.argb((int) 0, 227, 29, 26));//AGB由相关工具获得，或者美工提供
                    iv_home_btn_xiaoxi.setVisibility(View.VISIBLE);
                    iv_home_btn_xiaoxi_b.setVisibility(View.GONE);
                    tv_devider_home.setVisibility(View.GONE);
                } else if (y == 0) {
                    float scale = (float) y / 500;
                    float alpha = (0 * scale);
                    ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_w);
                    // 只是layout背景透明(仿知乎滑动效果)
                    search_ll.setBackgroundColor(Color.argb((int) alpha, 227, 29, 26));
                    iv_home_btn_xiaoxi.setVisibility(View.VISIBLE);
                    iv_home_btn_xiaoxi_b.setVisibility(View.GONE);
                    tv_devider_home.setVisibility(View.GONE);
                } else {
                    ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_h);
                    search_ll.setBackgroundColor(Color.argb((int) 255, 255, 250, 250));
                    tv_devider_home.setVisibility(View.VISIBLE);
                    iv_home_btn_xiaoxi.setVisibility(View.GONE);
                    iv_home_btn_xiaoxi_b.setVisibility(View.VISIBLE);
                }
            }
        });



        return viewLayout;
    }






    @Override
    public void onResume() {
        super.onResume();

        myRecycleViewAdapter = new TmallchoicenessAdapter(jDcomjPlistlist, getActivity(), "home");
        mRecyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false));
        mRecyclerview.setAdapter(myRecycleViewAdapter);
        myRecycleViewAdapter.notifyDataSetChanged();
        tmallchoicenessListAdapter = new TmallchoicenessListAdapter(getActivity(), jDcomjPlistlist, "home");
        list_xrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        list_xrecyclerView.setAdapter(tmallchoicenessListAdapter);
        tmallchoicenessListAdapter.notifyDataSetChanged();
    }

    @Override
    public void onStart() {
        super.onStart();
        myRecycleViewAdapter = new TmallchoicenessAdapter(jDcomjPlistlist, getActivity(), "home");
        mRecyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false));
        mRecyclerview.setAdapter(myRecycleViewAdapter);
        myRecycleViewAdapter.notifyDataSetChanged();
        tmallchoicenessListAdapter = new TmallchoicenessListAdapter(getActivity(), jDcomjPlistlist, "home");
        list_xrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        list_xrecyclerView.setAdapter(tmallchoicenessListAdapter);
        tmallchoicenessListAdapter.notifyDataSetChanged();
        if ("".equals(SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN) + "")) {
            ll_homeliving_huisheng_money.setVisibility(View.GONE);
            cycleViewPager_Cremoney.setVisibility(View.VISIBLE);
            LoadHomeCremoneyNull();
        } else {
            ll_homeliving_huisheng_money.setVisibility(View.VISIBLE);
            iv_advermoney_banner.setVisibility(View.GONE);
            cycleViewPager_Cremoney.setVisibility(View.GONE);
            //请求惠生钱数据
            LoadHomeCremoney();
        }

    }

    private void saveImage(List<String> imageUrls, final String cconten, final int type) {
        Log.v("shiran", "------------saveImage------------");
        final LoadingDialog dialog = new LoadingDialog(getActivity());
        dialog.setContent("正在生成图片请稍后");
        Observable.just(imageUrls)
                .map(new Function<List<String>, List<String>>() {

                    @Override
                    public List<String> apply(List<String> list) throws Exception {

                        List<String> paths = new ArrayList<String>();
                        for (String s : list) {
                            FutureTarget<File> future = Glide.with(APP.getInstance())
                                    .load(s)
                                    .downloadOnly(500, 500);
                            File cacheFile = future.get();
                            String uuid = UUID.randomUUID().toString();
                            FileIOUtils.writeFileFromIS(savePath + uuid + ".jpg", new FileInputStream(cacheFile));
                            String pat = savePath + uuid + ".jpg";
                            paths.add(pat);

                        }


                        return paths;
                    }
                }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<List<String>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        if (dialog != null && !dialog.isShowing()) {
                            dialog.show();
                        }
                    }

                    @Override
                    public void onNext(List<String> value) {
                        LogUtils.e(value);
                        if (dialog != null && dialog.isShowing()) {
                            dialog.dismiss();
                            dialog.cancel();
                        }

                        switch (type) {
                            case SHARET_WXHY:
                                ShareUtils.sharePicToFriendNoSDK(getActivity(), value);
                                break;
                            default:

                                break;
                        }

                    }

                    @Override
                    public void onError(Throwable e) {
                        if (dialog != null && dialog.isShowing()) {
                            dialog.dismiss();
                            dialog.cancel();
                        }
                    }

                    @Override
                    public void onComplete() {
                        if (dialog != null && dialog.isShowing()) {
                            dialog.dismiss();
                            dialog.cancel();
                        }
                    }
                });
    }
    private void initjplistHttp() {
        Log.e("优惠",GOODSURL+"?type=jing"+"&start="+curr+"&length=10");
        OkHttpUtils.post().url(GOODSURL).addParams("type","jing").addParams("start", curr+"").addParams("length",10+"").build().execute(new StringCallback() {
            @Override
            public void onError(Request request, Exception e) {

            }

            @Override
            public void onResponse(String response) {
                mRecyclerview.refreshComplete();
                initDatalist(response);

            }
        });
    }
    private void initDatalist(String response) {
        mRecyclerview.refreshComplete();
        Log.e("精选", response);
        Gson gson = new Gson();
        final JDcomjPlistBean jDcomjPlistBean = gson.fromJson(response, JDcomjPlistBean.class);
        if (jDcomjPlistBean != null && jDcomjPlistBean.getData() != null && jDcomjPlistBean.getData().getList() != null) {
            if (curr == 0) {
                jDcomjPlistlist.clear();
            }
            jDcomjPlistlist.addAll(jDcomjPlistBean.getData().getList());
            myRecycleViewAdapter.notifyDataSetChanged();
            myRecycleViewAdapter.setmMyItemclickListener(new TmallchoicenessAdapter.MyItemclickListener() {
                @Override
                public void itemclick(View view, int position) {



                    if (jDcomjPlistlist.get(position).getSpuPlatform().equals("yh")) {
                        Intent intent = new Intent(getActivity(), Red_PacketActivity.class);
                        intent.putExtra("shopid", jDcomjPlistlist.get(position).getId());
                        intent.putExtra("typex", jDcomjPlistlist.get(position).getSpuPlatform());
                        startActivity(intent);
                    } else {
                        location = position;
                        if (jDcomjPlistlist.get(position).getSpuPlatform().equals("yh")) {
                            Intent intent = new Intent(getActivity(), Red_PacketActivity.class);
                            intent.putExtra("shopid", jDcomjPlistlist.get(position).getId());
                            intent.putExtra("typex",jDcomjPlistlist.get(position).getSpuPlatform());
                            startActivity(intent);
                        } else {
                            if (jDcomjPlistlist.get(position).getSpuPlatform().equals("jd")) {
                                if (jDcomjPlistlist.get(position).getCouponMoney().equals("")) {
                                    initJDputong();
                                    if(KeplerApiManager.getWebViewService().isKeplerLogined()){
                                        try {
                                            KeplerApiManager.getWebViewService().openJDUrlWebViewPage(jDlianjiebean.getData() + "&userid" + SPUtils.getInstance().getString(SPConstants.KEY_USERID), "kepler_customer_Info");
                                        } catch (KeplerBufferOverflowException e) {
                                            e.printStackTrace();
                                        }

                                    }else {
                                        final LoginListener mLoginListener = new LoginListener() {
                                            @Override
                                            public void authSuccess(Object token) {
                                                // TODO Auto-generated method stub
                                                Toast.makeText(getActivity(), token + "", Toast.LENGTH_SHORT).show();
                                                //                showToken();

                                                if (KeplerApiManager.getWebViewService().isKeplerLogined()) {
                                                    try {
                                                        KeplerApiManager.getWebViewService().openJDUrlWebViewPage(jDlianjiebean.getData() + "&userid" + SPUtils.getInstance().getString(SPConstants.KEY_USERID), "kepler_customer_Info");
                                                    } catch (KeplerBufferOverflowException e) {
                                                        e.printStackTrace();
                                                    }
                                                }

                                            }

                                            @Override
                                            public void authFailed(int errorCode) {
                                                // TODO Auto-generated method stub
                                                switch (errorCode) {
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_Init:// 初始化失败 break;
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_InitIng:// 初始化没有完成 break;
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_openH5authPageURLSettingNull://跳转url // 为null break;
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_getTokenErr:// 获取失败(OAuth授权之后，获取cookie过程出错) break;
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_User_Cancel:// 用户取消 break;
                                                    case KeplerApiManager.KeplerApiManagerLoginErr_AuthErr_ActivityOpen://打开授权页面失败 break;
                                                    default:
                                                        break;
                                                }
                                                Log.e("jdSHOUQUAN", errorCode + ":authFailed");
                                            }
                                        };
                                        KeplerApiManager.getWebViewService().login(getActivity(), mLoginListener);

//
                                    }
                                }
                                if (jDcomjPlistlist.get(position).getCouponMoney() != "") {
                                    if (jDcomjPlistlist.get(position).getCouponMoney().equals("0.0")) {

                                        Map<String, String> map = new HashMap<>();
                                        map.put("token", SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN));
                                        map.put("spuId", jDcomjPlistlist.get(location).getId());
                                        map.put("appid", AUniqueIdentifier.getDeviceId(getActivity()));

                                        OkHttpUtils.post().params(map).url(ApiManager.BASE_NIUPAI_URL+jDcomjPlistlist.get(position).getSpuPlatform()+"/getConUrl").build().execute(new StringCallback() {
                                            @Override
                                            public void onError(Request request, Exception e) {

                                            }

                                            @Override
                                            public void onResponse(String response) {
                                                Log.e("优惠二和一数据", response);
                                                Gson gson = new Gson();
                                                jDlianjiebean = gson.fromJson(response, JDlianjie.class);
                                                datayouhui = jDlianjiebean.getData();
                                                if (jDlianjiebean.getCode().equals("10000")) {
                                                    Intent intent = new Intent(getActivity(), JDred_packetActivity.class);
                                                    intent.putExtra("shopid", jDcomjPlistlist.get(location).getId());
                                                    startActivity(intent);
                                                }
                                            }
                                        });

                                    } else {
                                        Log.e("优惠二和一链接接口", ApiManager.BASE_NIUPAI_URL+jDcomjPlistlist.get(position).getSpuPlatform()+"/getConUrl" + "?token=" + SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN) + "&spuId=" + jDcomjPlistlist.get(location).getId() + "&appid=" + AUniqueIdentifier.getDeviceId(getActivity()));
                                        Map<String, String> map = new HashMap<>();
                                        map.put("token", SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN));
                                        map.put("spuId", jDcomjPlistlist.get(location).getId());
                                        map.put("appid", AUniqueIdentifier.getDeviceId(getActivity()));

                                        OkHttpUtils.post().params(map).url(ApiManager.BASE_NIUPAI_URL+jDcomjPlistlist.get(position).getSpuPlatform()+"/getConUrl").build().execute(new StringCallback() {
                                            @Override
                                            public void onError(Request request, Exception e) {

                                            }

                                            @Override
                                            public void onResponse(String response) {
                                                Log.e("优惠二和一数据9", response);
                                                Gson gson = new Gson();
                                                jDlianjiebean = gson.fromJson(response, JDlianjie.class);
                                                datayouhui = jDlianjiebean.getData();
                                                if (jDlianjiebean.getCode().equals("10000")) {
                                                    if (jDlianjiebean.getData() != null) {
                                                        if(KeplerApiManager.getWebViewService().isKeplerLogined()){
                                                            try {
                                                                KeplerApiManager.getWebViewService().openJDUrlWebViewPage(jDlianjiebean.getData() + "&userid" + SPUtils.getInstance().getString(SPConstants.KEY_USERID), "kepler_customer_Info");
                                                            } catch (KeplerBufferOverflowException e) {
                                                                e.printStackTrace();
                                                            }

                                                        }else {
                                                            final LoginListener mLoginListener = new LoginListener() {
                                                                @Override
                                                                public void authSuccess(Object token) {
                                                                    // TODO Auto-generated method stub
                                                                    Toast.makeText(getActivity(), token + "", Toast.LENGTH_SHORT).show();


                                                                }

                                                                @Override
                                                                public void authFailed(int errorCode) {
                                                                    // TODO Auto-generated method stub
                                                                    switch (errorCode) {
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_Init:// 初始化失败 break;
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_InitIng:// 初始化没有完成 break;
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_openH5authPageURLSettingNull://跳转url // 为null break;
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_getTokenErr:// 获取失败(OAuth授权之后，获取cookie过程出错) break;
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_User_Cancel:// 用户取消 break;
                                                                        case KeplerApiManager.KeplerApiManagerLoginErr_AuthErr_ActivityOpen://打开授权页面失败 break;
                                                                        default:
                                                                            break;
                                                                    }
                                                                    Log.e("jdSHOUQUAN", errorCode + ":authFailed");
                                                                }
                                                            };
                                                            KeplerApiManager.getWebViewService().login(getActivity(), mLoginListener);
                                                            if (KeplerApiManager.getWebViewService().isKeplerLogined()) {
                                                                try {
                                                                    KeplerApiManager.getWebViewService().openJDUrlWebViewPage(jDlianjiebean.getData() + "&userid" + SPUtils.getInstance().getString(SPConstants.KEY_USERID), "kepler_customer_Info");
                                                                } catch (KeplerBufferOverflowException e) {
                                                                    e.printStackTrace();
                                                                }
                                                            }

                                                        }
                                                    }
                                                }
                                            }
                                        });
                                    }
                                }


                            }
                        }
                    }

                }
            });

            tmallchoicenessListAdapter.notifyDataSetChanged();
//            tmallchoicenessListAdapter.setmMylistItemclickListener(new TmallchoicenessListAdapter.MylistItemclickListener() {
//                @Override
//                public void listitemclick(View view, int position) {
//                    Intent intent = new Intent(getActivity(), Red_PacketActivity.class);
//                    intent.putExtra("shopid", jDcomjPlistlist.get(position).getId());
//                    intent.putExtra("typex", "yh");
//                    startActivity(intent);
//                }
//            });

        }
    }
    //普通二和一链接
    private void initJDputong(){
        try {
            Map<String, String> map = new HashMap<String, String>();
            map.put("spuId", jDcomjPlistlist.get(location).getId());
            map.put("appid", AUniqueIdentifier.getDeviceId(getActivity()));
            map.put("token", SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN));
            Log.e("京东二合一转链", ApiManager.BASE_NIUPAI_URL+jDcomjPlistlist.get(location).getSpuPlatform()+"/getUrl" + "?spuId=" + jDcomjPlistlist.get(location).getId() + "&appId=" + AUniqueIdentifier.getDeviceId(getActivity()) + "&token=" + SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN));
            OkHttpUtils.post().params(map).url(ApiManager.BASE_NIUPAI_URL+jDcomjPlistlist.get(location).getSpuPlatform()+"/getUrl").build().execute(new StringCallback() {
                @Override
                public void onError(Request request, Exception e) {

                }
                @Override
                public void onResponse(String response) {
                    Log.e("fgdgfe", response);
                    Gson gson = new Gson();
                    JDlianjie jDlianjie = gson.fromJson(response, JDlianjie.class);
                    datalisnajie = jDlianjie.getData();
                    Log.e("kfjsdkghdfk", datalisnajie);

                }
            });
        }catch (Exception e){

        }
    }
    /**
     * 检查用户是否登录
     * @param context
     * @param isNeedToLoginView true 表示需要跳转登录界面   false 只检查用户是否登录
     * @return
     */
    public static boolean isLogin(Context context, boolean isNeedToLoginView){
        String token =  SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN);

        if (!TextUtils.isEmpty(token)){
            return true;
        }
        if (isNeedToLoginView) {
            Intent intent = new Intent(context,LoginActivity.class);
            context.startActivity(intent);
            return false;
        }
        return false;
    }
    private void LoadIxTongRed() {

        String url = ApiManager.COUPON_SYS_LIST+"?token="+ SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN)+"&appId="+AUniqueIdentifier.getDeviceId(getActivity());
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                listred = gson.fromJson(responseInfo.result, RedBean.class);
                if(listred.getCode().equals("10000")) {

                    if(listred.getData().getIsOpen().equals("1")){
                        if(  listred.getData().getList().equals("")|| listred.getData().getList().size()==0){
                            ll_hongbao.setVisibility(View.GONE);
                            iv_cancel_dialog_red.setVisibility(View.GONE);
                        }else
                            ll_hongbao.setVisibility(View.VISIBLE);
                        iv_cancel_dialog_red.setVisibility(View.VISIBLE);
                        UtilsImage.uploadimageview( iv_redyouhuiquan,listred.getData().getCouponBg(),"",getActivity());
                        iv_redyouhuiquan.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                LoadIxTongRedlingwqu();
                            }
                        });
                    }else{
                        ll_hongbao.setVisibility(View.GONE);
                        iv_cancel_dialog_red.setVisibility(View.GONE);
                    }
                }else if(listred.getCode().equals("10001")){
                    Intent intent=new Intent(getActivity(),LoginActivity.class);
                    startActivity(intent);
                }else if(listred.getCode().equals("10002")){
                    Intent intent=new Intent(getActivity(),LoginActivity.class);
                    startActivity(intent);
                }else {
                    Toast.makeText(getActivity(),listred.getMsg(), Toast.LENGTH_SHORT).show();
                }


            }

            @Override

            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    private void LoadIxTongRedlingwqu() {
        for(int i=0;i<listred.getData().getList().size();i++){
            listid.add(listred.getData().getList().get(i).getId());
        }
        StringBuffer permission = new StringBuffer();
        for(int i=0;i<listid.size();i++){
            if(i == 0){
                permission.append(listid.get(i));
            }else{
                permission.append(","+listid.get(i));
            }
        }
        String url = ApiManager.COUPON_RECEIVE+"?token="+ SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN)+"&appId="+AUniqueIdentifier.getDeviceId(getActivity())+"&couponId="+permission.toString()+"&type="+"0";
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                try {

                    JSONObject obj=new JSONObject(responseInfo.result);
                    if(obj.getString("code").equals("10000")) {
                        iv_redyouhuiquan.setVisibility(View.GONE);
//                        Toast.makeText(getActivity(),obj.getString("msg"),Toast.LENGTH_SHORT).show();
                    }else if(obj.getString("code").equals("10001")){
                        Intent intent=new Intent(getActivity(),LoginActivity.class);
                        startActivity(intent);
                    }else if(obj.getString("code").equals("10002")){
                        Intent intent=new Intent(getActivity(),LoginActivity.class);
                        startActivity(intent);
                    }else {
                        Toast.makeText(getActivity(),obj.getString("msg"), Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }


            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    private void LoadIsShow() {
        String url = ApiManager.INDEX_ISSHOWCREMONEY;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                try {
                    JSONObject obj=new JSONObject(responseInfo.result);
                    if(obj.getString("code").equals("10000")) {
                        if(obj.getString("data").equals("hide")){
                            ll_web_container_home.setVisibility(View.GONE);
                            ll_homeliving_huisheng_money.setVisibility(View.GONE);
                        }else{
                            ll_web_container_home.setVisibility(View.VISIBLE);
                            ll_homeliving_huisheng_money.setVisibility(View.VISIBLE);
                        }
                    }else {
                        Toast.makeText(getActivity(), obj.getString("msg"), Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override

            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     *到帐消息推送
     */
    private void LoadHomeClinimsg(){
        String url = ApiManager.INDEX_CLINTMSG+"?token="+ SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN)+"&appId="+AUniqueIdentifier.getDeviceId(getActivity());;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                ClinimsgBean list = gson.fromJson(responseInfo.result, ClinimsgBean.class);
                if(list.getCode().equals("10000")) {
//                    Toast.makeText(getActivity(),list.getData(),Toast.LENGTH_LONG).show();
                    WebSettings webSettings = webview_home.getSettings();
                    //设置WebView属性，能够执行Javascript脚本
                    webSettings.setJavaScriptEnabled(true);
                    //设置可以访问文件
                    webSettings.setAllowFileAccess(true);
                    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
//                    //设置自适应屏幕，两者合用
                    webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
                    webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
                    String url=list.getData();
                    webview_home.loadUrl(url);
                    //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
                    webview_home.setWebViewClient(new WebViewClient(){
                        @Override
                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                            // TODO Auto-generated method stub
                            //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                            view.loadUrl(url);
                            return true;
                        }
                    });
                    webview_home.setWebChromeClient(new WebChromeClient());


                }else {
                    Toast.makeText(getActivity(), list.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     *惠生钱
     */
    private void LoadHomeCremoneyNull(){
        String url = ApiManager.INDEX_CREMONEY;
        Log.e("zhuti","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                listC = gson.fromJson(responseInfo.result, CremoneyBean.class);
                if(listC.getCode().equals("10000")) {
                    if(listC.getData().getCreAdverts().size()==1){
                        iv_advermoney_banner.setVisibility(View.VISIBLE);
                        ll_homeliving_huisheng_money.setVisibility(View.GONE);
                        cycleViewPager_Cremoney.setVisibility(View.GONE);

                        UtilsImage.uploadimageview(iv_advermoney_banner,listC.getData().getCreAdverts().get(0).getImg(),null,getActivity());
                    }else {
                        ll_homeliving_huisheng_money.setVisibility(View.GONE);
                        iv_advermoney_banner.setVisibility(View.GONE);
                        cycleViewPager_Cremoney.setVisibility(View.VISIBLE);

                        for (CremoneyBean.DataBean.CreAdvertsBean bean : listC.getData().getCreAdverts()) {

                            imagemory.add(bean.getImg());
                        }
                        initBannerViewmory();
                    }

                }else {
                    Toast.makeText(getActivity(), listC.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });


    }
    /**
     *惠生钱
     */
    private void LoadHomeCremoney(){

        String url = ApiManager.Index+"?token="+ SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN)+"&appId="+AUniqueIdentifier.getDeviceId(getActivity());;
        Log.e("惠生钱","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                Index index = gson.fromJson(responseInfo.result, Index.class);
                if(index.getCode().equals("10000")) {
                    Index.DataBean data = index.getData();

                    if (data.getUpOrDowm().equals("down")){
                        iv_homeliving_Rise.setImageResource(R.drawable.bianzhi1);
                    }else {
                        iv_homeliving_Rise.setImageResource(R.drawable.home_icon_shengzhi);
                    }

                    tv_today_money.setText(data.getTodayMoney()+"");
                    tv_homeliving_Available_balance.setText(data.getBalance()+"");
                    tv_homeliving_totalProfit.setText(data.getTotalMoney()+"");
                    tv_homeliving_totalComsum.setText(data.getConsume()+"");
                    circleBarView.setMaxNum(10);
                    circleBarView.setProgressNum(5f,1000);
                    tvprogress.setText(data.getYearRate()+"%"+"\n"+"年利率");


//                    imageViewkejian.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View v) {
//
//                            if (!iskejian){
//                                tv_homeliving_totalComsum.setVisibility(View.VISIBLE);
//                                imageViewkejian.setImageResource(R.drawable.home_icon_kejian);
//                                iskejian = true;
//                            }else {
//                                tv_homeliving_totalComsum.setVisibility(View.GONE);
//                                imageViewkejian.setImageResource(R.drawable.home_icon_bukejian);
//                                iskejian = false;
//                            }
//
//                        }
//                    });
                }else {
                    Toast.makeText(getActivity(), index.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });

        ll_homeliving_huisheng_money.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ShengQianActivity.class);
                startActivity(intent);
            }
        });





    }

    /**
     *广告图三
     */
    private void LoadHomeAdvertthree(){
        String url = ApiManager.INDEX_ADVERTTHREE;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                try{
                    Gson gson = new Gson();
                    listthre = gson.fromJson(responseInfo.result, Advertthreethree.class);
                    if(listthre.getCode().equals("10000")) {
                        if(listthre.getData().size()==1) {
                            iv_advertwo.setVisibility(View.VISIBLE);
                            UtilsImage.uploadimageview(iv_advertwo, listthre.getData().get(0).getImg(), null, getActivity());
                            iv_advertwo.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                                    intent.putExtra("id",listthre.getData().get(0).getId());
                                    startActivity(intent);
                                }
                            });
                            cycleViewPager_thre.setVisibility(View.GONE);

                        }else if(listthre.getData().size()==0){
                            iv_advertwo.setVisibility(View.GONE);
                            cycleViewPager_thre.setVisibility(View.GONE);
                        }else{
                            iv_advertwo.setVisibility(View.GONE);
                            cycleViewPager_thre.setVisibility(View.VISIBLE);
                            for (Advertthreethree.DataBean bean : listthre.getData()) {
                                imagethre.add(bean.getImg());
                            }
                            initBannerViewthre();
                        }
                    }else {
                        Toast.makeText(getActivity(), listthre.getMsg(), Toast.LENGTH_SHORT).show();
                    }
                }catch (JsonSyntaxException e){
                    Toast.makeText(getActivity(),"解析错误",Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     *广告图二
     */
    private void LoadHomeAdverttwo(){
        String url = ApiManager.INDEX_ADVERTTWO;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                listtwo = gson.fromJson(responseInfo.result, AdverttwoBean.class);
                if(listtwo.getCode().equals("10000")) {
                    if(listtwo.getData().size()==1) {
                        iv_advertone.setVisibility(View.VISIBLE);
                        cycleViewPager_two.setVisibility(View.GONE);
                        UtilsImage.uploadimageview(iv_advertone, listtwo.getData().get(0).getImg(), null, getActivity());
                        iv_advertone.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent=new Intent(getActivity(),Specialactivity.class);
                                intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                                intent.putExtra("id",listtwo.getData().get(0).getId());
                                startActivity(intent);
                            }
                        });
                    }else if(listtwo.getData().size()==0){
                        iv_advertone.setVisibility(View.GONE);
                        cycleViewPager_two.setVisibility(View.GONE);
                    }else{
                        iv_advertone.setVisibility(View.GONE);
                        cycleViewPager_two.setVisibility(View.VISIBLE);
                        for (AdverttwoBean.DataBean bean : listtwo.getData()) {
                            imagetwo.add(bean.getImg());
                        }


                        initBannerViewtwo();
                    }
                }else {
                    Toast.makeText(getActivity(), listtwo.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    /**
     *广告图一
     */
    private void LoadHomeAdvertone(){
        String url = ApiManager.INDEX_ADVERTONE;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                listone = gson.fromJson(responseInfo.result, AdvertoneBean.class);
                if(listone.getCode().equals("10000")) {
                    if (listone.getData().size()==1) {
                        iv_adverthree.setVisibility(View.VISIBLE);
                        cycleViewPager_one.setVisibility(View.GONE);
                        UtilsImage.uploadimageview(iv_adverthree, listone.getData().get(0).getImg(), null, getActivity());
                        iv_adverthree.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent=new Intent(getActivity(),Specialactivity.class);
                                intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                                intent.putExtra("id",listone.getData().get(0).getId());
                                startActivity(intent);
                            }
                        });
                    }else if(listone.getData().size()==0){
                        iv_adverthree.setVisibility(View.GONE);
                        cycleViewPager_one.setVisibility(View.GONE);
                    }else{
                        iv_adverthree.setVisibility(View.GONE);
                        cycleViewPager_one.setVisibility(View.VISIBLE);

                        for (AdvertoneBean.DataBean bean : listone.getData()) {
                            imageone.add(bean.getImg());
                        }
                        initBannerViewone();
                    }
                }else {
                    Toast.makeText(getActivity(), listone.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    /**
     * 加载热门活动
     */
    private void LoadHomeHoting(){
        String url = ApiManager.INDEX_HOTING;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                HotingBean list = gson.fromJson(responseInfo.result, HotingBean.class);
                if(list.getCode().equals("10000")) {
                    if(list.getData().size()==0) {
                        ll_remenhuodong.setVisibility(View.GONE);
                    }else {
                        ll_remenhuodong.setVisibility(View.VISIBLE);
                        HomeLivingMoneyPopularActivitiesViewAdapter popularAdapter = new HomeLivingMoneyPopularActivitiesViewAdapter(getActivity(), list.getData());
                        gv_homeliving_Popular_activities.setAdapter(popularAdapter);
                    }
                }else {
                    Toast.makeText(getActivity(), list.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     * 加载排行榜
     */
    private void LoadHomeRanking(){
        String url = ApiManager.INDEX_RANKING;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                final RankingBean list = gson.fromJson(responseInfo.result, RankingBean.class);
                if(list.getCode().equals("10000")) {
                    for(int i=0;i<list.getData().size();i++){
                        if(list.getData().size()==1){
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo1,list.getData().get(0).getImg(),null,getActivity());
                            iv_home_ranking_ranNo2.setVisibility(View.GONE);
                            iv_home_ranking_ranNo3.setVisibility(View.GONE);
                            iv_home_ranking_ranNo4.setVisibility(View.GONE);
                            iv_home_ranking_ranNo5.setVisibility(View.GONE);
                        }else if(list.getData().size()==2){
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo1,list.getData().get(0).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo2,list.getData().get(1).getImg(),null,getActivity());
                            iv_home_ranking_ranNo3.setVisibility(View.GONE);
                            iv_home_ranking_ranNo4.setVisibility(View.GONE);
                            iv_home_ranking_ranNo5.setVisibility(View.GONE);
                        }else if(list.getData().size()==3){
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo1,list.getData().get(0).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo2,list.getData().get(1).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo3,list.getData().get(2).getImg(),null,getActivity());
                            iv_home_ranking_ranNo4.setVisibility(View.GONE);
                            iv_home_ranking_ranNo5.setVisibility(View.GONE);
                        }else if(list.getData().size()==4){
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo1,list.getData().get(0).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo2,list.getData().get(1).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo3,list.getData().get(2).getImg(),null,getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo4,list.getData().get(3).getImg(),null,getActivity());
                            iv_home_ranking_ranNo5.setVisibility(View.GONE);
                        }else {

                            UtilsImage.uploadimageview(iv_home_ranking_ranNo1, list.getData().get(0).getImg(), null, getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo2, list.getData().get(1).getImg(), null, getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo3, list.getData().get(2).getImg(), null, getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo4, list.getData().get(3).getImg(), null, getActivity());
                            UtilsImage.uploadimageview(iv_home_ranking_ranNo5, list.getData().get(4).getImg(), null, getActivity());
                        }
                        iv_home_ranking_ranNo1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if(list.getData().get(0).getLinkType().equals("h5")){
                                    Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                                    intent.putExtra("url",list.getData().get(0).getValue());
                                    intent.putExtra("title","专题");
                                    startActivity(intent);
                                }else if(list.getData().get(0).getLinkType().equals("app")){
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ACTIVITYDETAIL);
                                    intent.putExtra("id",list.getData().get(0).getId());
                                    startActivity(intent);
                                }
                            }
                        });
                        iv_home_ranking_ranNo2.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if(list.getData().get(1).getLinkType().equals("h5")){
                                    Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                                    intent.putExtra("url",list.getData().get(1).getValue());
                                    intent.putExtra("title","专题");
                                    startActivity(intent);
                                }else if(list.getData().get(1).getLinkType().equals("app")){
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ACTIVITYDETAIL);
                                    intent.putExtra("id",list.getData().get(1).getId());
                                    startActivity(intent);
                                }
                            }
                        });
                        iv_home_ranking_ranNo3.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if(list.getData().get(2).getLinkType().equals("h5")){
                                    Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                                    intent.putExtra("url",list.getData().get(2).getValue());
                                    intent.putExtra("title","专题");
                                    startActivity(intent);
                                }else if(list.getData().get(2).getLinkType().equals("app")){
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("id",list.getData().get(2).getId());
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ACTIVITYDETAIL);
                                    startActivity(intent);
                                }
                            }
                        });
                        iv_home_ranking_ranNo4.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if(list.getData().get(3).getLinkType().equals("h5")){
                                    Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                                    intent.putExtra("url",list.getData().get(3).getValue());
                                    intent.putExtra("title","专题");
                                    startActivity(intent);
                                }else if(list.getData().get(3).getLinkType().equals("app")){
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("id",list.getData().get(3).getId());
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ACTIVITYDETAIL);
                                    startActivity(intent);
                                }
                            }
                        });
                        iv_home_ranking_ranNo5.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if(list.getData().get(4).getLinkType().equals("h5")){
                                    Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                                    intent.putExtra("url",list.getData().get(4).getValue());
                                    intent.putExtra("title","专题");
                                    startActivity(intent);
                                }else if(list.getData().get(4).getLinkType().equals("app")){
                                    Intent intent=new Intent(getActivity(),Specialactivity.class);
                                    intent.putExtra("id",list.getData().get(4).getId());
                                    intent.putExtra("urlmarket",ApiManager.MARKET_ACTIVITYDETAIL);
                                    startActivity(intent);
                                }
                            }
                        });


                    }

                }else {
                    Toast.makeText(getActivity(), list.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    /**
     * 加载发现好货
     */
    private void LoadHomeGoodfinds(){
        String url = ApiManager.INDEX_FINDGOOD;
        Log.e("主题","主题url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                GoodFindBean list = gson.fromJson(responseInfo.result, GoodFindBean.class);
                if(list.getCode().equals("10000")) {
                    if(list.getData().size()==0){
                        ll_faxianhaohuo.setVisibility(View.GONE);
                    }else{
                        ll_faxianhaohuo.setVisibility(View.VISIBLE);

                        HomeLivingMoneyFindGoodGoodsViewAdapter findAdapter=new HomeLivingMoneyFindGoodGoodsViewAdapter(getActivity(),list.getData());
                        gv_homeliving_findGoodGoods.setAdapter(findAdapter);
                    }
                }else {
                    Toast.makeText(getActivity(), list.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }
    /**
     * 加载主题
     */
    private void LoadHomeModels(){
        String url = ApiManager.INDEX_MODELS+"?token="+ SPUtils.getInstance().getString(SPConstants.KEY_USER_TOKEN)+"&appId="+AUniqueIdentifier.getDeviceId(getActivity());
        Log.e("首页gridview","主题url===="+url);
        HttpUtils http = new HttpUtils();

        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                ModelsBean list = gson.fromJson(responseInfo.result, ModelsBean.class);
                if(list.getCode().equals("10000")) {
                    HomeLivingMoneyTGridViewAdapter adapter=new HomeLivingMoneyTGridViewAdapter(getActivity(),list.getData());
                    gv_homeliving_gridviewT.setAdapter(adapter);
                }else {
                    Toast.makeText(getActivity(), list.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     * 加载轮播
     */
    private void LoadHomeBanners(){
        String url = ApiManager.INDEX_BANNERS;
        Log.e("lunbo","url===="+url);
        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                listban = gson.fromJson(responseInfo.result, BannersBean.class);
                if(listban.getCode().equals("10000")) {
                    if(listban.getData().size()==0){

                    }else {


                        for (BannersBean.DataBean bean : listban.getData()) {
                            image.add(bean.getImg());
                        }
                        initBannerView();
                    }
                }else {
                    Toast.makeText(getActivity(), listban.getMsg(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(getActivity(),"失败",Toast.LENGTH_SHORT).show();
            }
        });
    }


    @Override
    public void onScrollChanged(ObservableScrollView scrollView, int x, int y,
                                int oldx, int oldy) {
        // TODO Auto-generated method stub
        Log.i("TAG","x----->"+x+ "y--->" + y + "    height-->" +oldx+"    "+oldy);
        if (y <= 0) {
            ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_w);
            search_ll.setBackgroundColor(Color.argb((int) 0, 227, 29, 26));//AGB由相关工具获得，或者美工提供
            iv_home_btn_xiaoxi.setVisibility(View.VISIBLE);
            iv_home_btn_xiaoxi_b.setVisibility(View.GONE);
            tv_devider_home.setVisibility(View.GONE);
        } else if (y > 0 && y <= 500) {
            float scale = (float) y / 500;
            float alpha = (0 * scale);
            ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_w);
            // 只是layout背景透明(仿知乎滑动效果)
            search_ll.setBackgroundColor(Color.argb((int) alpha, 227, 29, 26));
            iv_home_btn_xiaoxi.setVisibility(View.VISIBLE);
            iv_home_btn_xiaoxi_b.setVisibility(View.GONE);
            tv_devider_home.setVisibility(View.GONE);
        } else {
            ll_home_sear.setBackgroundResource(R.drawable.img_shousuo_h);
            search_ll.setBackgroundColor(Color.argb((int) 255, 255, 250, 250));
            tv_devider_home.setVisibility(View.VISIBLE);
//            search_ll.setBackgroundColor(Color.argb((int) 0, 227, 29, 26));
            iv_home_btn_xiaoxi.setVisibility(View.GONE);
            iv_home_btn_xiaoxi_b.setVisibility(View.VISIBLE);
        }
    }

    //setbanner轮播图数据
    private void initBannerViewthre() {
        try {
            cycleViewPager_thre.setImageLoader(new GlideImageLoader());
            //设置图片集合

            cycleViewPager_thre.setImages(imagethre);
            //banner设置方法全部调用完毕时最后调用
            cycleViewPager_thre.start();
            cycleViewPager_thre.setOnBannerListener(new OnBannerListener() {
                @Override
                public void OnBannerClick(int position) {
                    if(listthre.getData().get(position).getLinkType().equals("h5")){
                        Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                        intent.putExtra("url",listthre.getData().get(position).getValue());
                        intent.putExtra("title","专题");
                        startActivity(intent);
                    }else if(listthre.getData().get(position).getLinkType().equals("app")){
                        Intent intent=new Intent(getActivity(),Specialactivity.class);
                        intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                        intent.putExtra("id",listthre.getData().get(position).getId());
                        startActivity(intent);
                    }
                }
            });
        }catch (Exception e){

        }
    }
    //setbanner轮播图数据
    private void initBannerViewtwo() {
        try {
            cycleViewPager_two.setImageLoader(new GlideImageLoader());
            //设置图片集合
            cycleViewPager_two.setDelayTime(4000);
            cycleViewPager_two.setImages(imagetwo);
            //banner设置方法全部调用完毕时最后调用
            cycleViewPager_two.start();
            cycleViewPager_two.setOnBannerListener(new OnBannerListener() {
                @Override
                public void OnBannerClick(int position) {
                    if(listtwo.getData().get(position).getLinkType().equals("h5")){
                        Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                        intent.putExtra("url",listthre.getData().get(position).getValue());
                        intent.putExtra("title","专题");
                        startActivity(intent);
                    }else if(listtwo.getData().get(position).getLinkType().equals("app")){
                        Intent intent=new Intent(getActivity(),Specialactivity.class);
                        intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                        intent.putExtra("id",listtwo.getData().get(position).getId());
                        startActivity(intent);
                    }
                }
            });
        }catch (Exception e){

        }
    }

    //setbanner轮播图数据
    private void initBannerViewone() {
        try {
            cycleViewPager_one.setImageLoader(new GlideImageLoader());
            //设置图片集合

            cycleViewPager_one.setImages(imageone);
            //banner设置方法全部调用完毕时最后调用
            cycleViewPager_one.start();
            cycleViewPager_one.setOnBannerListener(new OnBannerListener() {
                @Override
                public void OnBannerClick(int position) {
                    if(listone.getData().get(position).getLinkType().equals("h5")){
                        Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                        intent.putExtra("url",listone.getData().get(position).getValue());
                        intent.putExtra("title","专题");
                        startActivity(intent);
                    }else
                    if(listone.getData().get(position).getValue().equals("login")){
                        Intent intent=new Intent(getActivity(), LoginActivity.class);
                        startActivity(intent);
                    }else if(listone.getData().get(position).getValue().equals("app")){
                        Intent intent=new Intent(getActivity(),Specialactivity.class);
                        intent.putExtra("urlmarket",ApiManager.MARKET_ADVERTDETAIL);
                        intent.putExtra("id",listone.getData().get(position).getId());
                        startActivity(intent);
                    }
                }
            });
        }catch (Exception e){

        }
    }
    //setbanner轮播图数据
    private void initBannerViewmory() {
        try {
            cycleViewPager_Cremoney.setImageLoader(new GlideImageLoader());
            //设置图片集合
            cycleViewPager_Cremoney.setImages(imagemory);
            //banner设置方法全部调用完毕时最后调用
            cycleViewPager_Cremoney.start();



            cycleViewPager_Cremoney.setOnBannerListener(new OnBannerListener() {
                @Override
                public void OnBannerClick(int position) {
                    if(listC.getData().getCreAdverts().get(position).getLinkType().equals("h5")){
                        Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                        intent.putExtra("url",listC.getData().getCreAdverts().get(position).getValue());
                        intent.putExtra("title","专题");
                        startActivity(intent);
                    }else if(listC.getData().getCreAdverts().get(position).getLinkType().equals("app")){
                        Intent intent=new Intent(getActivity(),Specialactivity.class);
                        intent.putExtra("urlmarket",ApiManager.MARKET_BANNERDETAIL);
                        intent.putExtra("id",listC.getData().getCreAdverts().get(position).getId());
                        startActivity(intent);
                    }else if(listC.getData().getCreAdverts().get(position).getLinkType().equals("login")){
                        Intent intent=new Intent(getActivity(), LoginActivity.class);
                        startActivity(intent);
                    }
                }
            });
        }catch (Exception e){

        }
    }
    //setbanner轮播图数据
    private void initBannerView() {
        try {
            cycleViewPager.setImageLoader(new GlideImageLoader());
            //设置图片集合
            cycleViewPager.setDelayTime(4000);
            cycleViewPager.setImages(image);
            //banner设置方法全部调用完毕时最后调用
            cycleViewPager.start();
            cycleViewPager.setOnBannerListener(new OnBannerListener() {
                @Override
                public void OnBannerClick(int position) {
                    if(listban.getData().get(position).getLinkType().equals("h5")){
                        Intent intent=new Intent(getActivity(),RankingRanNo1HtmlActivity.class);
                        intent.putExtra("url",listban.getData().get(position).getValue());
                        intent.putExtra("title","专题");
                        startActivity(intent);
                    }else if(listban.getData().get(position).getLinkType().equals("app")){
                        Intent intent=new Intent(getActivity(),Specialactivity.class);
                        intent.putExtra("urlmarket",ApiManager.MARKET_BANNERDETAIL);
                        intent.putExtra("id",listban.getData().get(position).getId());
                        startActivity(intent);
                    }
                }
            });
        }catch (Exception e){

        }
    }




}
